package com.tingyukeji.fastpay.base;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import com.mcxiaoke.bus.Bus;

/**
 * Created by Administrator on 2016/11/8.
 */

public class BaseActivity extends AppCompatActivity {
    protected Context context;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        context = this;
        Bus.getDefault().register(this);
        setContentView();
        initView();
    }

    protected void initView() {
    }


    protected void setContentView() {
    }

    protected void goActivity(Class<?> activity) {
        Intent intent = new Intent();
        intent.setClass(this, activity);
        startActivity(intent);
    }

    protected void goActivity(Class<?> activity, Bundle bundle) {
        Intent intent = new Intent();
        intent.setClass(this, activity);
        intent.putExtras(bundle);
        startActivity(intent);
    }

    protected void goActivity(Class<?> activity, Bundle bundle, int requestCode) {
        Intent intent = new Intent();
        intent.setClass(this, activity);
        intent.putExtras(bundle);
        startActivityForResult(intent, requestCode);
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        Bus.getDefault().unregister(this);
    }

    @Override
    public void onPause() {
        super.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
    }
}
